package 迭代器模式;

import 迭代器模式.接口.Goods;
import 迭代器模式.接口.MyIterator;

public class Client {
    public static void main(String[] args) {
        Goods goods = new GoodsImpl();

        MyIterator myIterator = goods.getMyIterator();//获取迭代器

        //往后遍历
        System.out.println("=====================往后遍历==========================");
        while (myIterator.hasNext()){
            System.out.println(myIterator.getCurrent());//输出当前的值
            myIterator.next();//指向下一个
        }


        //此时指针在最后，往前遍历
        System.out.println("=====================往前遍历==========================");
        myIterator.lasst();//将游标指向最后一个元素
        while (myIterator.hasPri()){
            System.out.println(myIterator.getCurrent());
            myIterator.pri();
        }
    }

}
